package com.ljf.jdvideo.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.HeadlessException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import com.ljf.jdvideo.jd.DownVideo;

public class UI extends JFrame {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public UI() throws HeadlessException {
        super();
        JTextArea mesg =new JTextArea();
        mesg.setAutoscrolls(true);
        mesg.setWrapStyleWord(true);
        mesg.setEditable(false);
        
        JPanel urlPanel = new JPanel(new FlowLayout(0,10,10));
        JLabel urlName = new JLabel("网址:");
        JTextField urlText = new JTextField(50);
        urlPanel.add(urlName);
        urlPanel.add(urlText);
        

        JButton down = new JButton("下载视频");
        down.addActionListener((e) -> {
            new Thread(new DownVideo(urlText.getText(), mesg)).start();
        });
        urlPanel.add(down);
        
        this.setLayout(new BorderLayout());
        this.add(BorderLayout.NORTH,urlPanel);
        this.add(BorderLayout.CENTER,mesg);
//        this.add(BorderLayout.SOUTH,down);
        
        this.setSize(800 , 500);
        this.setLocation(500,200);//设置窗体的显示位置
        this.setVisible(true);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setAlwaysOnTop(true);
    }

}
